// 云函数入口文件
const cloud = require('wx-server-sdk')
// 云开发环境初始化
cloud.init({env: cloud.DYNAMIC_CURRENT_ENV})
exports.main = async (event, context) => {
  const db = cloud.database()
  console.log(event.id)
  let count = await db.collection('comment').where({
    cai:event.id
  }).count()
  count = count.total
  let all = []
  for (let i = 0; i < count; i += 100) {
    let list = await db.collection('comment').where({
      cai:event.id
    }).orderBy("second","desc").skip(i).get()
    all = all.concat(list.data);
  }
  return all;
}
